using System;
using System.Collections.Generic;
using System.Text;
using XiaoGang.Soft.XGWMS.COM;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    class DAL_ComProcess_SQL
    {

        #region SQL

        #region Get_MaxID_SQL

        private static string _get_MaxID_SQL = @"SELECT (CAST(GETID_DIV AS CHAR(2))+ 
CAST(FISCAL_YEAR AS CHAR(4))+ 
STUFF('000000',1,len(NEWEST_NO+1),'')+CONVERT(CHAR(6),(NEWEST_NO+1)) 
) AS SLIPID,(NEWEST_NO + 1) AS NEWEST_NO FROM M011_GET_ID WHERE GETID_DIV = @GETID_DIV AND FISCAL_YEAR = @FISCAL_YEAR";

        #endregion

        #region Check_Exist_MaxID_SQL

        private static string _check_Exist_MaxID_SQL = @"SELECT * FROM M011_GET_ID WHERE GETID_DIV = @GETID_DIV AND FISCAL_YEAR = @FISCAL_YEAR";

        #endregion

        #region Update_MaxID_SQL

        public static string _update_MaxID_SQL = @"UPDATE M011_GET_ID 
SET 
    UPDATE_DATETIME = " + CONST.CurrentTime + ",TRANS_STATE = '2' , UPDATER_ID = @UPDATER_ID , TERMINAL_CD = @TERMINAL_CD , NEWEST_NO = @NEWEST_NO WHERE GETID_DIV = @GETID_DIV AND FISCAL_YEAR = @FISCAL_YEAR ";

        #endregion

        #region Add_MaxID_SQL

        public static string _add_MaxID_SQL = @"INSERT INTO M011_GET_ID 
    (CREATE_DATETIME , 
    UPDATE_DATETIME , 
    TRANS_STATE , 
    UPDATER_ID , 
    TERMINAL_CD , 
    GETID_DIV , 
    FISCAL_YEAR , 
    START_NO , 
    END_NO , 
    NEWEST_NO ) 
VALUES (" + CONST.CurrentTime + "," + CONST.CurrentTime + ",'1',@UPDATER_ID ,@TERMINAL_CD ,@GETID_DIV ,@FISCAL_YEAR ,@START_NO ,@END_NO ,@NEWEST_NO )";

        #endregion

        #endregion

        #region

        /// <summary>
        /// Get_MaxID
        /// </summary>
        public static string Get_MaxID
        {
            get { return _get_MaxID_SQL; }
        }

        /// <summary>
        /// Check_Exist_MaxID
        /// </summary>
        public static string Check_Exist_MaxID
        {
            get { return _check_Exist_MaxID_SQL;}
        }

        /// <summary>
        /// Update_MaxID
        /// </summary>
        public static string Update_MaxID
        {
            get { return _update_MaxID_SQL; }
        }

        /// <summary>
        /// Add_MaxID
        /// </summary>
        public static string Add_MaxID
        {
            get { return _add_MaxID_SQL; }
        }

        #endregion
    }
}
